package com.shop.controller;

import com.shop.annotation.RequiresPermissionsDesc;
import com.shop.pojo.DtsCollect;
import com.shop.service.DtsCollectService;
import com.shop.util.ResponseUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @ClassName AdminCollectController
 * @Author xiao宋
 * @Date 19:42  2022/10/15
 * @Version 1.0
 * @Description TODO
 */
@Slf4j
@RestController
@RequestMapping("/admin/collect")
public class AdminCollectController {
    @Autowired
    DtsCollectService collectService;

    @RequiresPermissions("admin:user:list")
    @RequiresPermissionsDesc(menu = {"系统管理", "角色管理"}, button = "会员收藏")
    @GetMapping("/list")
    public Object UserList(
            @RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
            @RequestParam(value = "limit", required = false, defaultValue = "20") Integer limit,
            @RequestParam(value = "sort", required = false, defaultValue = "add_time") String sort,
            @RequestParam(value = "order", required = false, defaultValue = "desc") String order,
            Integer valueId, Integer userId
    ) {
        log.debug("显示会员收藏分页方法");
        log.debug("前端传过来的每页条数：{}，第几页：{}", page, limit);
        Map<String, Object> data = collectService.findByPage(page, limit, sort, order, valueId, userId);
        log.debug("会员收藏分页方法显示完毕");
        return ResponseUtil.ok(data);
    }
}
